<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: user_tips.tpl.php 1126 2008-06-09 05:45:04Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>

<script type="text/javascript" src="<?php echo JL_URL_FOLDER;?>/js/wz_jsgraphics.js"></script>

<?php 
  require_once JL_FRONTEND_PATH."/js/pie.js.php";

?>
<div id="joomleague">
<!-- Header with Project Name-->
<?php if ($doTips_config['show_project_heading'] == "1" OR $overall_config['show_project_heading'] == "1") { ?>
<div class="componentheading" <?php if ($doTips_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
<!-- Druckfunktion -->
<?php if ($doTips_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") {
$htmlHelper->PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->
<?php } ?>
<!-- Header END -->

<!-- Bereichs�berschrift z.B Tabelle, Tippabgabe usw. bei Bedarf mit Drucksymbol -->
<table width="100%" class="contentpaneopen">
	<tr>
		<td <?php if (($user_is_tippadmin == 0) || ($usetipadmin==0)) { ?>class="contentheading"><?php }
		if (($user_is_tippadmin == 0) || ($usetipadmin==0)) { echo _JL_TIPS;?><?php echo sprintf("%s. %s",$current_round, _JL_MATCHDAY); }?></td>
     <?php if ($doTips_config['show_matchday_dropdown'] == "1") echo '<td style="text-align:right" nowrap="nowrap">'
        ._JL_MATCHDAYS_SELECT.$pageNav2.'</td>';?>  
	</tr>
     <?php if (($user_is_tippadmin == 1) && ($usetipadmin==1)) {?>
	<tr>
		<td class="contentheading"><?php echo _JL_TIPS;?><?php echo sprintf("%s. %s",$current_round, _JL_MATCHDAY);?></td>
<?php     echo '<td style="text-align:right" nowrap="nowrap">User ausw�hlen: '.$pageNav3.'</td>';?>  
    </tr>
<?php } ?>
</table>
<!-- Bereichs�berschrift Ende -->

<form name="adminForm" action="<?php echo JL_COMPONENT_LINK.'&amp;func=doTips&amp;p='.$joomleague->id.JL_ITEMID_SUFFIX;?>" method="post">
<input type="hidden" name="p" value="<?php echo $joomleague->id;?>" />
<input type="hidden" name="r" value="<?php echo $current_round;?>" />
<input type="hidden" name="user_id" value="<?php echo $user_id;?>" />

<!-- Anzahl der Spieltage berechnen -->
<?php 
  $counter = 0;
  $rlimit = count($rounds);
  foreach($rounds as $round){
    if($counter == count($rounds)/2 && count($rounds) > 34) echo '<br />';
    $counter++;
  }  
?>
<!-- Berechnung Ende, Ausgabe erfolgt unten -->
<br />
<!-- Inhalt -->
<table width="96%" style="text-align:center" border="0" cellpadding="3" cellspacing="0">


<tr>
    <td style="text-align:right">&nbsp;</td>
    <td style="text-align:center">&nbsp;</td>
    <td style="text-align:left">&nbsp;</td>
    <td style="text-align:center"><b><?php echo _JL_RESULT;?></b></td>
    <td style="text-align:center"><b>&nbsp;</b></td>
    <td style="text-align:center"><b><?php echo _JL_TIPS_MY_TIP;?></b></td>
    <?php if (($joomleague->tip_joker == 1) && ($joomleague->mode==0)) { ?> 
    <td style="text-align:center"><b><?php echo _JL_TIPS_JOKER;?></b> <?php
    if ($joomleague->tip_joker_limit>0) echo sprintf('(%s/%s)',$joker_count, $joomleague->tip_joker_limit); ?></td>
    <?php } ?>
    <td style="text-align:right"><b><?php echo _JL_TIPS_MY_POINTS;?></b></td>
  </tr>
<?php
  				
    $counter=1;
    $k = 0;
    $round_date = '';
    $total = 0;
    $savable = false;
	$endofjoker=$joomleague->getTimestamp($tips[0]->round_date);
//	$thistime=date("Y-m-d H:i:s");
	$thistime=$joomleague->getTimestamp('',1);
	
	if (count($tips)) {
    foreach($tips as $tip){
      
      $total += $tip->point;
      
      if ($tip->e1 == "") { 
        $tip->e1 = "-";
	  }
 	  if ($tip->e2 == "") { 
        $tip->e2 = "-";
 	  }

	  if ($tip->overtime == "1") { 
        $mrt = "n.V";
      }
      else if ($tip->overtime == "2"){  
        $mrt = "n.E";
      }
      else if ($tip->decision == 1){  // $tip->v1 == true ge�ndert auf $tip->decision == 1  --> stefan47110815 (23.04.2007)
        $mrt = "*";
      }      
/***    Auskommentiert, da Ergebnis am gr�nen Tisch anders abgefragt wird --> stefan47110815 (23.04.2007)
      else if ($tip->v2 == true){  
        $mrt = "*";
      }          ***/
      else{
        $mrt = "";
      } 		  
      
		// $tip->decision ist f�r die gr�ne Tischentscheidung ma�gebend --> stefan47110815 (23.04.2007)
	  if ($tip->decision==0) {
	    $e1=$tip->e1;
		$e2=$tip->e2;
	  }
	  else {
		$e1=$tip->v1;
		$e2=$tip->v2;
	  }
	
      if($round_date != $joomleague->getTimestamp($tip->round_date)) {
        
//        $datum = split("-| |:",$tip->round_date);
        $round_date = $joomleague->getTimestamp($tip->round_date);
//        $round_date = $tip->round_date;
?>
        <tr class="sectiontableheader">
        <?php if ($joomleague->tip_joker == 1) { ?> 
          <td colspan="8" class="sectiontableheader"><?php echo mosFormatDate($tip->round_date, _JL_DATE, 0);?></td>
        <?php } else { ?>
          <td colspan="7" class="sectiontableheader"><?php echo mosFormatDate($tip->round_date, _JL_DATE, 0);?></td>
        <?php }?>
        </tr>
<?php
        
      }
      
      $class = ($k == 0)? 'sectiontableentry1' : 'sectiontableentry2';
      
      if((($round_date > $thistime) && (($user_is_tippadmin == 0) || ($usetipadmin==0))) ||
        (($user_is_tippadmin == 1) && ($usetipadmin==1) && ($user_id<>''))){
        $savable = true;
        if($joomleague->mode == 0){
        //tip
?>

  <tr class="<?php print $class;?>">
    <td style="text-align:right"><?php echo $tip->home;?></td>
    <td style="text-align:center">-</td>
    <td style="text-align:left"><?php echo $tip->away;?></td>
    <td style="text-align:center"><?php echo sprintf("%s:%s",$e1,$e2);?></td>  <!-- $tip->e1 und $tip->e2 ge�ndert in $e1 und $e2  stefan47110815 (23.04.2007)-->  
    <td style="text-align:center" width="5"><?php echo $mrt;?></td>
    <td style="text-align:center" nowrap="nowrap">
    <?php if (($e1 == "-"&&$e2 == "-") || (($user_is_tippadmin == 1) && ($usetipadmin==1))) {   // $tip->e1 und $tip->e2 ge�ndert in $e1 und $e2 --> stefan47110815 (23.04.2007)?>
      <input type="hidden" name="cids[]" value="<?php echo $tip->match_id; ?>" />
      <input type="hidden" name="<?php printf("id_%s", $tip->match_id);?>" value="<?php echo $tip->id; ?>" />
      <input type="text" name="<?php printf("tip_home_%s", $tip->match_id);?>" class="inputbox" size="2" value="<?php
      echo $tip->tip_home;?>" tabindex="1" />&nbsp;:
      <input type="text" name="<?php printf("tip_away_%s", $tip->match_id);?>" class="inputbox" size="2" value="<?php
      echo $tip->tip_away;?>" tabindex="1" />
    </td>    
    <?php if ($joomleague->tip_joker == 1) { ?>
    <td style="text-align:center">
    <?php if (($thistime < $endofjoker || ($user_is_tippadmin == 1 && $usetipadmin==1) && $user_id<>'') && ($joker_allowed == 1)) { ?>
    <input type="radio" name="joker" value="j<?php echo $tip->match_id;?>" <?php if ($tip->joker==1) echo 'checked="checked"';?>/></td>
  <?php } else { ?>
  	<input type="radio" name="joker" value="j<?php echo $tip->match_id;?>" disabled="disabled" <?php
  	if ($tip->joker==1) echo 'checked="checked"';?>/><?php if ($tip->joker==1) { ?><input type="hidden" value="j<?php
  	  echo $tip->match_id;?>" name="joker" /><?php } ?></td>
  <?php } ?>
    
    <?php } ?>
    <?php }
    else echo sprintf("%s:%s",$tip->tip_home,$tip->tip_away);?>

    
    <td style="text-align:right"><?php echo $tip->point;?></td>
  </tr>

<?php
        }
        else{
        //toto
          $toto = array();
          $toto[] = mosHTML::makeOption( '', _JL_TIPS_NO_TIP );  
          $toto[] = mosHTML::makeOption( '0', _JL_TIPS_0 );  
          $toto[] = mosHTML::makeOption( '1', _JL_TIPS_1 );
          $toto[] = mosHTML::makeOption( '2', _JL_TIPS_2 );
?>
    <tr class="<?php print $class;?>">
      <input type="hidden" name="cids[]" value="<?php echo $tip->match_id; ?>"/>
      <input type="hidden" name="<?php printf("id_%s", $tip->match_id);?>" value="<?php echo $tip->id; ?>"/>
      <td style="text-align:right"><?php echo $tip->home;?></td>
      <td style="text-align:center">-</td>
      <td style="text-align:left"><?php echo $tip->away;?></td>
      <td style="text-align:center"><?php echo sprintf("%s:%s",$e1,$e2);  // $tip->e1 und $tip->e2 ge�ndert in $e1 und $e2 --> stefan47110815 (23.04.2007)?></td>
    <td style="text-align:center" width="5"><?php echo $mrt;?></td>
      <td style="text-align:center">
        <?php echo mosHTML::selectList($toto,'tip_'.$tip->match_id, 'size="1" class="inputbox"', 'value','text', $tip->tip);?>
      </td>
    <td style="text-align:right"><?php echo $tip->point;?></td>
  </tr>
<?php
        }
      }
      else{
?>
  <tr class="<?php print $class;?>">
    <td style="text-align:right"><?php echo $tip->home;?></td>
    <td style="text-align:center">-</td>
    <td style="text-align:left"><?php echo $tip->away;?></td>
    <td style="text-align:center">
<?php
/***    Auskommentiert, da Ergebnis am gr�nen Tisch anders abgefragt wird --> stefan47110815 (23.04.2007)
     if (is_null($tip->v1)) $e1=$tip->e1; else $e1=$tip->v1;
     if (is_null($tip->v2)) $e2=$tip->e2; else $e2=$tip->v2;
		***/
		printf("%s:%s",$e1,$e2);?></td>
<td style="text-align:center" width="5"><?php echo $mrt;?></td>
    <td style="text-align:center"><?php if ($joomleague->mode == 0 ) echo sprintf("%s:%s",$tip->tip_home,$tip->tip_away);
    else echo sprintf("%s",$tip->tip);?></td>
    <?php if (($joomleague->tip_joker == 1) && ($joomleague->mode == 0)) { ?> 
    <td style="text-align:center">
     <input type="radio" name="joker" value="j<?php echo $tip->match_id;?>" disabled="disabled" <?php
     if ($tip->joker==1) echo 'checked="checked"';?>/>
    </td>
    <?php } ?>
    <td style="text-align:right"><?php echo $tip->point;?></td>
  </tr>
<?php
      }
?>
<!-- Tipptendenz anzeigen? -->
<?php if ($doTips_config['show_tip_tendence'] == "1"){;?>
<tr><td colspan="8">
<div id="div_<?php echo $tip->match_id;?>" style="overflow: auto; position:relative;height:80px;width:98%;"></div>

<script type="text/javascript">
// <![CDATA[ 
 var p<?php echo $tip->match_id;?> = new pie();
 
 <?php //if($heimsiege[$tip->match_id]>0) { 
 	?>
 p<?php echo $tip->match_id;?>.add("<?php echo  _JL_TIPS_WIN_HOME;?><?php echo $heimsiege[$tip->match_id];?><?php echo  _JL_TIPS_TIPS;?>",<?php
  echo $heimsiege[$tip->match_id];?>);
<?php  
//}  if($unentschieden[$tip->match_id]>0) { 
	?>
 p<?php echo $tip->match_id;?>.add("<?php echo  _JL_TIPS_DRAW;?><?php echo $unentschieden[$tip->match_id];?><?php echo  _JL_TIPS_TIPS;?>",<?php
  echo $unentschieden[$tip->match_id];?>);
<?php //}
//if($auswaertssiege[$tip->match_id]>0) { 
	?>
 p<?php echo $tip->match_id;?>.add("<?php echo  _JL_TIPS_WIN_AWAY;?><?php echo $auswaertssiege[$tip->match_id];?><?php echo  _JL_TIPS_TIPS;?>",<?php
  echo $auswaertssiege[$tip->match_id];?>);
<?php 
//}
 ?>
 p<?php echo $tip->match_id;?>.render("div_<?php echo $tip->match_id;?>", "Tippstatistik", 80);

// ]]>
</script>
<br />
</td></tr>
<?php };?>
<!-- Tipptendenz Ende -->

<?php
      $k = 1 - $k;
  	  $counter++;
    }
  }
  if($savable){
?>


<?php 
    } 
    if (($joomleague->tip_joker == 1) && ($joomleague->mode==0)) { ?> 
  <tr class="<?php print $class;?>"> 
    <td colspan="6"><div style="text-align:right"><?php echo _JL_TIPS_NO_JOKER; ?></div></td>
    <td style="text-align:center"><input type="radio" name="joker" value="nojoker"<?php if ((($thistime<$endofjoker)
    || (($user_is_tippadmin == 1) && ($usetipadmin==1) && ($user_id<>''))) && ($joker_allowed==1)) echo ''; else echo ' disabled="disabled"';?><?php
    if ($joker_set==0) echo ' checked="checked"';?> /></td>
    <td>&nbsp;</td>
  </tr>
<?php } ?>
</table>
<table width="96%" style="text-align:center" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td width="10%" style="text-align:left"></td>
    <td width="80%" style="text-align:center"><input type="submit" class="button" name="saveTips" tabindex="2" onclick="return confirm('<?php
    echo _JL_TIPS_POPUP;?>')" value="<?php echo _JL_SAVE;?> "/></td>
    <td width="10%" style="text-align:right"><?php printf("<b>%s %s</b>", $total, _JL_TIPS_POINTS);?></td>
  </tr>
</table>
</form>

<!-- Ausgabe der Spieltage -->
<?php if ($doTips_config['show_matchday_pagenav'] == "1"){;?>
<table width="96%" style="text-align:center" border="0" cellpadding="3" cellspacing="0">
  <tr>
   <td style="text-align:center"><br />
  <?php echo $pageNav ?>
<br /></td>
  </tr>
</table>
<?php } ;?>
<!-- Ausgabe der Spieltage Ende -->

<?php if ($doTips_config['show_help'] == "1"){
$helptext = str_replace('$NL$', "<br />", $doTips_config['help_text']);
$helptext = str_replace('$DL$', "<br /><br />", $helptext);?>
<br />
<table width="96%" style="text-align:center" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td valign="top" width="15%" nowrap="nowrap"><b><?php echo _JL_HINT;?></b></td>
    <td style="text-align:left"><?php echo $helptext;?></td>
  </tr>
</table>
<?php } ;?>
<!-- Inhalt Ende -->

<!-- Print Button START -->
<?php if ($doTips_config['show_back_button'] > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($doTips_config['show_back_button'] == "1" OR $overall_config['show_back_button'] == "1") echo '<div style="text-align:left">'; else echo '<div style="text-align:right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
?></div> 
<?php };?>
<!-- Print Button END -->  
</div>
